// --------------------------------------------------------------------------------------------
// Version: MPL 1.1/GPL 2.0/LGPL 2.1
// 
// The contents of this file are subject to the Mozilla Public License Version
// 1.1 (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
// http://www.mozilla.org/MPL/
// 
// Software distributed under the License is distributed on an "AS IS" basis,
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
// for the specific language governing rights and limitations under the
// License.
// 
// <remarks>
// Generated by IDLImporter from file nsIAuthModule.idl
// 
// You should use these interfaces when you access the COM objects defined in the mentioned
// IDL/IDH file.
// </remarks>
// --------------------------------------------------------------------------------------------
namespace Gecko
{
	using System;
	using System.Runtime.InteropServices;
	using System.Runtime.InteropServices.ComTypes;
	using System.Runtime.CompilerServices;
	
	
	/// <summary>
    ///This Source Code Form is subject to the terms of the Mozilla Public
    /// License, v. 2.0. If a copy of the MPL was not distributed with this
    /// file, You can obtain one at http://mozilla.org/MPL/2.0/. </summary>
	[ComImport()]
	[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
	[Guid("6e35dbc0-49ef-4e2c-b1ea-b72ec64450a2")]
	public interface nsIAuthModule
	{
		
		/// <summary>
        /// Called to initialize an auth module.  The other methods cannot be called
        /// unless this method succeeds.
        ///
        /// @param aServiceName
        /// the service name, which may be null if not applicable (e.g., for
        /// NTLM, this parameter should be null).
        /// @param aServiceFlags
        /// a bitwise-or of the REQ_ flags defined above (pass REQ_DEFAULT
        /// for default behavior).
        /// @param aDomain
        /// the authentication domain, which may be null if not applicable.
        /// @param aUsername
        /// the user's login name
        /// @param aPassword
        /// the user's password
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		void Init([MarshalAs(UnmanagedType.LPStr)] string aServiceName, uint aServiceFlags, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Gecko.CustomMarshalers.WStringMarshaler")] string aDomain, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Gecko.CustomMarshalers.WStringMarshaler")] string aUsername, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Gecko.CustomMarshalers.WStringMarshaler")] string aPassword);
		
		/// <summary>
        /// Called to get the next token in a sequence of authentication steps.
        ///
        /// @param aInToken
        /// A buffer containing the input token (e.g., a challenge from a
        /// server).  This may be null.
        /// @param aInTokenLength
        /// The length of the input token.
        /// @param aOutToken
        /// If getNextToken succeeds, then aOutToken will point to a buffer
        /// to be sent in response to the server challenge.  The length of
        /// this buffer is given by aOutTokenLength.  The buffer at aOutToken
        /// must be recycled with a call to free.
        /// @param aOutTokenLength
        /// If getNextToken succeeds, then aOutTokenLength contains the
        /// length of the buffer (number of bytes) pointed to by aOutToken.
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		void GetNextToken(System.IntPtr aInToken, uint aInTokenLength, ref System.IntPtr aOutToken, ref uint aOutTokenLength);
		
		/// <summary>
        /// Once a security context has been established through calls to GetNextToken()
        /// it may be used to protect data exchanged between client and server. Calls
        /// to Wrap() are used to protect items of data to be sent to the server.
        ///
        /// @param aInToken
        /// A buffer containing the data to be sent to the server
        /// @param aInTokenLength
        /// The length of the input token
        /// @param confidential
        /// If set to true, Wrap() will encrypt the data, otherwise data will
        /// just be integrity protected (checksummed)
        /// @param aOutToken
        /// A buffer containing the resulting data to be sent to the server
        /// @param aOutTokenLength
        /// The length of the output token buffer
        ///
        /// Wrap() may return NS_ERROR_NOT_IMPLEMENTED, if the underlying authentication
        /// mechanism does not support security layers.
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		void Wrap(System.IntPtr aInToken, uint aInTokenLength, [MarshalAs(UnmanagedType.U1)] bool confidential, ref System.IntPtr aOutToken, ref uint aOutTokenLength);
		
		/// <summary>
        /// Unwrap() is used to unpack, decrypt, and verify the checksums on data
        /// returned by a server when security layers are in use.
        ///
        /// @param aInToken
        /// A buffer containing the data received from the server
        /// @param aInTokenLength
        /// The length of the input token
        /// @param aOutToken
        /// A buffer containing the plaintext data from the server
        /// @param aOutTokenLength
        /// The length of the output token buffer
        ///
        /// Unwrap() may return NS_ERROR_NOT_IMPLEMENTED, if the underlying
        /// authentication mechanism does not support security layers.
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		void Unwrap(System.IntPtr aInToken, uint aInTokenLength, ref System.IntPtr aOutToken, ref uint aOutTokenLength);
	}
	
	/// <summary>nsIAuthModuleConsts </summary>
	public class nsIAuthModuleConsts
	{
		
		// <summary>
        // Default behavior.
        // </summary>
		public const ulong REQ_DEFAULT = 0;
		
		// <summary>
        // Client and server will be authenticated.
        // </summary>
		public const ulong REQ_MUTUAL_AUTH = (1<<0);
		
		// <summary>
        // The server is allowed to impersonate the client.  The REQ_MUTUAL_AUTH
        // flag may also need to be specified in order for this flag to take
        // effect.
        // </summary>
		public const ulong REQ_DELEGATE = (1<<1);
		
		// <summary>
        // The authentication is required for a proxy connection.
        // </summary>
		public const ulong REQ_PROXY_AUTH = (1<<2);
		
		// <summary>
        // Flags used for telemetry.
        // </summary>
		public const ulong NTLM_MODULE_SAMBA_AUTH_PROXY = 0;
		
		// 
		public const ulong NTLM_MODULE_SAMBA_AUTH_DIRECT = 1;
		
		// 
		public const ulong NTLM_MODULE_WIN_API_PROXY = 2;
		
		// 
		public const ulong NTLM_MODULE_WIN_API_DIRECT = 3;
		
		// 
		public const ulong NTLM_MODULE_GENERIC_PROXY = 4;
		
		// 
		public const ulong NTLM_MODULE_GENERIC_DIRECT = 5;
		
		// 
		public const ulong NTLM_MODULE_KERBEROS_PROXY = 6;
		
		// 
		public const ulong NTLM_MODULE_KERBEROS_DIRECT = 7;
	}
}
